<script>
	import Vue from 'vue'
	window.config = {
//			api: 'http://172.16.5.251:8080/',									//小彭 api 地址
		//	api: 'http://172.16.1.69:8080/exchange-mobile/',					//69 api 地址
		api: 'http://lhang.radarwin.com/', //93 api 地址
//		api: 'https://lhang.com/',									//lhang api 地址
		source: '2', //h5 请求必带的一个状态
//		socket_host: 'wss://mobile.lhang.com/ws/transport', //lhang socket 地址
//		  socket_host: 'ws://172.16.1.69:8080/exchange-mobile/transport',		//69 socket 地址
//			socket_host: 'ws://172.16.1.93/ws/transport',						//93 socket 地址
			socket_host: 'ws://lhang.radarwin.com/ws/transport',				//93 socket 地址
//			socket_host: 'ws://172.16.5.200:8080/transport',						//小彭 socket 地址
	}

	//	Vue.prototype.lh_config = config;

	Vue.prototype.lh_http = function(type, url, params) {
		var q;
		var result;
		q = $.Deferred();
		let _url = config.api + url
		if(type == 'post' || type == 'POST') {
			$.ajax(_url, {
				type: 'post',
				data: params,
				dataType: "json",
				crossDomain: true,
				headers: {
					//					'Content-Type': 'application/x-ww-form-urlencoded',
				},
				success: function(data, textStatus, request) {
					if(data.status == 0) {
						result = {
							data: data.dataWrapper,
							status: true,
						}
					} else {
						result = {
							data: data.msg,
							status: false,
						}
					}
					q.resolve(
						result,
					);
				},
				error: function(e) {
					q.reject(e);
					console.log(e)
				}
			})
		} else {
			$.ajax(_url, {
				type: 'get',
				data: params,
				dataType: "json",
				crossDomain: true,
				headers: {
					//					'Content-Type': 'application/x-ww-form-urlencoded',
				},
				success: function(data, textStatus, request) {
					if(data.status == 0) {
						result = {
							data: data.dataWrapper,
							status: true,
						}
					} else {
						result = {
							data: data.msg,
							status: false,
						}
					}
					q.resolve(
						result,
					);
				},
				error: function(e) {
					q.reject(e);
					console.log(e)
				}
			})
		}
		return q.promise();
	}
</script>